package com.zige.zige;


import android.app.Application;
import android.text.TextUtils;

import com.ta.util.cache.TAFileCache;
import com.umeng.socialize.PlatformConfig;
import com.zige.zige.bean.HomeBean;
import com.zige.zige.bean.Menubean;
import com.zige.zige.pojo.UserInfo;

import java.util.ArrayList;

import cn.jpush.android.api.JPushInterface;

public class LittleZebraApplication extends Application {

	private static class SingletonHolder {
		private static LittleZebraApplication instance = new LittleZebraApplication();
	}

	public static LittleZebraApplication getInstance() {
		return SingletonHolder.instance;
	}


	private TAFileCache mFileCache;
	private boolean isMianNeedRefresh;
	public void setMainNeedRefresh(boolean b) {
		isMianNeedRefresh = b;
	}

	public boolean getMainNeedRefresh() {
		return isMianNeedRefresh;
	}


	@Override
	public void onCreate() {
		super.onCreate();
		setShareData();
	}

	private UserInfo userInfo;

	public UserInfo getUserInfo() {
		return userInfo;
	}

	public void setUserInfo(UserInfo userInfo) {
		this.userInfo = userInfo;
	}
	public boolean isLogin() {
		if (userInfo == null || TextUtils.isEmpty(userInfo.userID)) {
			return false;
		}
		return true;
	}

	private UserInfo registerUser;
	public UserInfo getRegisterUser() {
		return registerUser;
	}
	public void setRegitserUser(UserInfo user) {
		this.registerUser = user;
	}

	private HomeBean homeBean;

	public HomeBean getHomeBean() {
		return homeBean;
	}

	public void setHomeBean(HomeBean homeBean) {
		this.homeBean = homeBean;
	}

	private ArrayList<Menubean> menubean = new ArrayList<Menubean>();
	public ArrayList<Menubean> getMenubean() {
		return menubean;
	}
	public void setMenubean(ArrayList<Menubean> menubean) {
		this.menubean = menubean;
	}

	/****
	 * 配置分享相关参数
	 */
	private void setShareData(){
		/**配置新浪微博相关参数*/
		PlatformConfig.setSinaWeibo("707648744","ce77f0c7ac9cb18470b60e9bf6395ee2");
		/**配置微信相关参数*/
		PlatformConfig.setWeixin("wxc9069ac1c4bac79e","50d5714b23bfe8749c76125bf93f2468");

		isMianNeedRefresh = false;
	}

	public TAFileCache getFileCache() {
		if(this.mFileCache == null) {
			TAFileCache.TACacheParams cacheParams = new TAFileCache.TACacheParams(this, "littlezebra");
			TAFileCache fileCache = new TAFileCache(cacheParams);
			this.setFileCache(fileCache);
		}

		return this.mFileCache;
	}

	public void setFileCache(TAFileCache fileCache) {
		this.mFileCache = fileCache;
	}

}
